<?php
namespace app\admin\controller;
use think\Controller;
//use think\Db;
use app\admin\Model\User as UserModel;
class Rest extends Controller {
	//重置或者更新信息控制器

	/**
	 * 重置用户密码
	 * 通过登陆记录的session获取用户的权限
	 */
	public function repassword() {
		$method = $this -> request -> method();
		$password = $this -> request -> param("password");
		$repassword = $this -> request -> param("repassword");
		session_start();
		//开启session
		$arr = $_SESSION["user"];
		//获得已经登陆的用户信息；
		$id = $arr["id"];
		$user = UserModel::get($id);
		if ($method == "POST" && $user -> password == $password) {
			$user -> password = $repassword;
			$user -> save();
			if (!$user -> save()) {
				$this -> success('修改密码成功！', '/', 1);
			}
		} else {
			return FALSE;
		}

	}
}
?>